package com.example.tests;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.utils.SortedListOf;

public class GroupModificationTests extends TestBase{
	
	@Test(dataProvider = "ramdomValidGroupGenerator")
	
	public void modifySomeGroupe(GroupData group){
	    
	    //save old state
		SortedListOf<GroupData> oldList =  app.getGroupHelper().getGroups();
	    
	    int index = getRandomIndex(oldList.size());
	    
	    //actions
		app.getGroupHelper().modifyGroup(index, group);

		
	    //save new state
		SortedListOf<GroupData> newList =  app.getGroupHelper().getGroups();   
	    
	    //compare states    
		assertThat(newList, equalTo(oldList.without(index).withAdded(group)));

		
	}

}
